package com.it;

public class ObtainDomainName {
    public static void main(String[] args) {
        String s1 = "www.aliyun.cn.com";
        String s2 = "https://www.baidu.com";

        String interceptDomainName = getInterceptDomainName(s1);//aliyun
        System.out.println("interceptDomainName = " + interceptDomainName);

        String interceptDomainName1 = getInterceptDomainName(s2);//baidu
        System.out.println("interceptDomainName1 = " + interceptDomainName1);
    }

    private static String getInterceptDomainName(String string) {
        int i1 = string.indexOf(".");//获取第一次出现的索引位置
        int i2 = string.indexOf(".", i1 + 1);//获取第二次出现的索引位置
        String substring = string.substring(i1 + 1, i2);
        return substring;
    }


}
